-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd: add detection for containers and pid1 #248
Conversation
@cjdcordeiro @hpidcock Could I kindly use your expertise to scrutinise the proposed change to the boot id code for containers, as well as the container detection logic? |
35aaad6
to
9494855
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments but otherwise looks ok.
|
||
// ResetContainerInit forces the container runtime check | ||
// to retry with globals reset | ||
func ResetContainerInit() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this if we seperate out the logic from the variable/sync
|
||
// MockPid2ProcPath assigns a temporary path to where the PID2 | ||
// status can be found. | ||
func MockPid2ProcPath(path string) (restore func()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, if we allow the implementation to be tested directly, we don't need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nifty! It seems there's no more straightforward way to tell from a child PID namespace that a process is in a child PID namespace. Besides comments by Harry, LGTM.
EDIT: OK, it can by thwarted by --pid host
as in the comment above.
The system manager currently makes some assumptions about the environment it is running in. For example, it assumes that a shutdown program is available in userspace and accessible with PATH configured appropriately. internals/daemon/daemon.go: : cmd := exec.Command("shutdown", "-r", ... : This patch adds two detection mechanisms that will allow code to make environment specific decisions in the future (not part of this patch): - cmd.IsConfined() returns true if running inside a container runtime - cmd.IsInit() returns true if the system manager was started as PID 1 In addition, the overlord code currently disables reboot failure detection if the system manager is running as PID 1. However, this change is only required for container runtimes, and not generically. - Update the boot id workaround code to only apply for container runtimes.
baba647
to
9c11f29
Compare
Sorry people for talking your time for reviews on this, but it was agreed the scope at which I was trying to solve my own little problem is too inflated here, so I am going to have to close this for now. Perhaps this will be needed again. The next person to find this closed PR with a hope to detect container runtimes / VMs - have a look here: |
The system manager currently makes some assumptions about the environment it is running in.
For example, it assumes that a shutdown program is available in userspace and accessible with PATH configured appropriately.
internals/daemon/daemon.go:
:
cmd := exec.Command("shutdown", "-r", ...
:
This patch adds two detection mechanisms that will allow code to make environment specific decisions in the future (not part of this patch):
cmd.IsConfined() returns true if running inside a container runtime
cmd.IsInit() returns true if the system manager was started as PID 1
In addition, the overlord code currently disables reboot failure detection if the system manager is running as PID 1. However, this change is only required for container runtimes, and not generically.